package com.yanqu.road.sync.message;

import com.yanqu.road.server.command.CommandControl;
import com.yanqu.road.server.command.ICrossServiceCommand;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.HashMap;
import java.util.Map;

public class Service {
    private  final Map<Integer, ICrossServiceCommand> crossServiceCommandHashMap = new HashMap<>();
    private  Logger logger = LogManager.getLogger(CommandControl.class.getName());

    public ICrossServiceCommand getCommand(int code) {
        try {
            return crossServiceCommandHashMap.get(code);
        } catch (Exception e) {
            logger.error("获取 Command 异常, Command Code: {}", code, e);
            return null;
        }
    }
    public Service() {
    }

    public void addCrossServiceCommand(int code, ICrossServiceCommand iCrossServiceCommand) {
        crossServiceCommandHashMap.put(code, iCrossServiceCommand);
    }


}
